package Oct_2020.part7;

import org.junit.Test;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

import static java.lang.Integer.*;

public class ace {
    public static void main(String[] args) throws ParseException {
        char[] c = {'a', 'b', 'c'};
        String s = new String(c);
        String as = new String(c);
        System.out.println(s == as);
// false
        String s2 = "hi";
        String s3 = "hi";
        System.out.println(s2 == s3);
//        true

//        Integer
        System.out.println(parseInt("12345"));

//          Date
        Scanner scan = new Scanner(System.in);
        String d = scan.nextLine();
        SimpleDateFormat p = new SimpleDateFormat("yyyy-MM-dd");
        Date u = p.parse(d);
        long bir = u.getTime();
        long now = System.currentTimeMillis();
        System.out.println((now - bir) / 1000 / 60 / 60 / 24);


    }

    @Test
    public void run() {
        Integer in = new Integer(10);
        System.out.println(valueOf(5));//转换为字符串
        System.out.println(in.intValue());//转换为整数
    }

    @Test
    public void ran() {
        Date d = new Date();
        System.out.println(d.getTime());
        System.out.println(d.getMinutes());
        System.out.println(d.getDate());
    }

    @Test
    public void r_SimpleDate() throws ParseException {
        String d = "2020=10-20";
        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
        Date u = s.parse(d);
        System.out.println(u.getYear());
        System.out.println(u.getMinutes());
        System.out.println(u.getDay());

        System.out.println(s.format(new Date()));


    }
    @Test
    public void r_BigDecimal () {
        System.out.println(2.0-1.1);
        BigDecimal c=new BigDecimal(String.valueOf(2.0));
        BigDecimal d=new BigDecimal("1.1");
        System.out.println(c.subtract(d));
        System.out.println(c.multiply(d));
//        对象，保留位数，舍入模式
        System.out.println(d.divide(c));
        System.out.println(c.divide(d,20,BigDecimal.ROUND_HALF_UP));

    }


}
